﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace jnlamp.Web.api
{
    public partial class state_get : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string sim_id = Request["sim_id"];
                if (!string.IsNullOrEmpty(sim_id))
                {

                    jnlamp.BLL.scdstatus sm = new BLL.scdstatus();

                    List<jnlamp.Model.scdstatus> ls = sm.GetModelList(" gprs_id='"+sim_id.Trim()+"'  order by uptime desc ");

                    if (ls.Count > 0)
                    {
                        jnlamp.Model.scdstatus s = ls[0];
                        string rets = "";
                        string vf = "";

                        if (s.ts < 10)
                        {
                            rets = "0" + s.ts;
                        }
                        else
                        {
                            rets = s.ts.ToString();
                        }
                        if (s.vf < 10)
                        {
                            vf = "0" + s.vf;
                        }
                        else
                        {
                            vf = s.vf.ToString();
                        }
                        Response.Write("STATE" + s.opt + "|" + s.kdsj + "|" + s.kdsc + "|" + rets + "|" + vf);
                    }
                    else
                    {
                        Response.Write("IDERR");
                    }
                }
            }
        }
    }
}